package com.shuoyue.ycgk.ui.mine.mynote.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseViewHolder;
import com.shuoyue.ycgk.R;
import com.shuoyue.ycgk.base.baseadapter.AppBaseQuickAdapter;
import com.shuoyue.ycgk.entity.PersonNote;
import com.shuoyue.ycgk.utils.GlideUtil;
import com.shuoyue.ycgk.utils.MyRichTextHelper;
import com.zzhoujay.richtext.ImageHolder;
import com.zzhoujay.richtext.RichText;

import java.util.List;

public class PersonNoteQuestionAdapter extends AppBaseQuickAdapter<PersonNote> {
    int isLike = 0;//是否点赞，0是我的笔记、1是我的点赞

    public PersonNoteQuestionAdapter(@Nullable List<PersonNote> data, int isLike) {
        super(R.layout.item_question_note, data);
        this.isLike = isLike;
    }

    @Override
    protected void convert(BaseViewHolder helper, PersonNote item) {
        helper.addOnClickListener(R.id.question_title);
        helper.addOnClickListener(R.id.lay_praise);
        helper.addOnClickListener(R.id.delete);
        helper.setGone(R.id.delete, isLike == 0);
        helper.setText(R.id.name, item.getUsername());
        helper.setText(R.id.time, item.getCreateTime());
        helper.setText(R.id.content, item.getNotes());
        helper.setText(R.id.praiseNum, String.valueOf(item.getLikeCount()));
        MyRichTextHelper.showRich(mContext, item.getStem(), helper.getView(R.id.question_title));
        GlideUtil.loadImageCircular(mContext, item.getAvatar(), R.mipmap.index_head, helper.getView(R.id.head));
        helper.setImageResource(R.id.img_praise, item.getIsLike() == 1 ? R.mipmap.icon_raise_y : R.mipmap.icon_raise_n);

    }
}
